package demo;

import com.pi4j.io.gpio.GpioController;
import com.pi4j.io.gpio.GpioFactory;
import com.pi4j.io.gpio.GpioPinDigitalOutput;
import com.pi4j.io.gpio.PinState;
import com.pi4j.io.gpio.RaspiPin;
import com.pi4j.system.SystemInfo;

public class LedController {
	public static void main(String[] args) throws Exception {
		System.out.println("Serial Number:" + SystemInfo.getSerial());
		System.out.println("CPU Revision:" + SystemInfo.getCpuRevision());
		System.out.println("CPU Temperature:" + String.valueOf(SystemInfo.getCpuTemperature()));
		System.out.println("CPU Core Voltage:" + String.valueOf(SystemInfo.getCpuVoltage()));
		// 创建一个GPIO控制器
		final GpioController gpio = GpioFactory.getInstance();
		final GpioPinDigitalOutput pin = gpio.provisionDigitalOutputPin(  
                RaspiPin.GPIO_00, "LED", PinState.HIGH);  
		while (true) {
			// 设置高电平
			pin.high();
			System.out.println("打开继电器");
			// 睡眠1秒
			Thread.sleep(1000);
			// 设置低电平
			pin.low();
			System.out.println("关闭继电器");
			Thread.sleep(1000);
			// 切换状态
			// pin.toggle();
		}
	}
}
